package com.leetcode.utils;

import java.util.Set;

public class ThreadUtils {

	public static void sleep(long millis) {
		try {
			Thread.sleep(millis);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}

	/**
	 * @param id
	 *
	 * @return null if not fit id
	 */
	public static Thread getThreadById(long id) {
		Set<Thread> threads = Thread.getAllStackTraces().keySet();
		for (Thread thread : threads) {
			if (thread.getId() == id) {
				return thread;
			}
		}
		return null;
	}
}
